package com.example.myapplication;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);}

        public void onOldButtonClicked(View view){
        AlertDialog dialog;
        dialog=new AlertDialog.Builder(this)
                .setTitle("旧版显示对话框")
                .setMessage("这是旧版的对话框，使用简单\n但是没有自动支持屏幕翻转!")
                .setIcon(R.mipmap.ic_launcher)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(getApplicationContext(),"你确定了",Toast.LENGTH_SHORT).show();
                    }
                })
                .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Toast.makeText(getApplicationContext(),"你取消了",Toast.LENGTH_SHORT).show();
                    }
                })
                .create();
        dialog.show();


        }


    public void onSimpleDialogFragment(View view)
    {
        SimpleDialogFragment dialog=new SimpleDialogFragment();
        dialog.show(getSupportFragmentManager(),"simple");
    }
    public void onChoiceDialogFragment(View view)
    {
        ChoiceDialogFragment dialog=new ChoiceDialogFragment();
        dialog.setListener(new ChoiceDialogFragment.NotifyDialogListener() {
            @Override
            public void onDialogPositiveClicked(String gender) {
                Toast.makeText(getApplicationContext(),"你选择了："+gender,Toast.LENGTH_SHORT).show();
            }
        });


        dialog.show(getSupportFragmentManager(),"choice");
    }

    public void onDaChoiceDialogFragment(View view)
    {
        DaChoiceDialogFragment dialog=new DaChoiceDialogFragment();
        dialog.setListener(new DaChoiceDialogFragment.NotifyDialogListener() {
            @Override
            public void onDialogPositiveClicked(String gender) {
                Toast.makeText(getApplicationContext(),"你选择了："+gender,Toast.LENGTH_SHORT).show();
            }
        });


        dialog.show(getSupportFragmentManager(),"choice");
    }
    public void onMoreChoiceDialogFragment(View view)
    {
        MoreChoiceDialogFragment dialog=new MoreChoiceDialogFragment();
        dialog.setListener(new DaChoiceDialogFragment.NotifyDialogListener() {
            @Override
            public void onDialogPositiveClicked(String gender) {
                Toast.makeText(getApplicationContext(),"你选择了："+gender,Toast.LENGTH_SHORT).show();
            }
        });


        dialog.show(getSupportFragmentManager(),"choice");
    }
    public void onCustomChoiceDialogFragment(View view)
    {
        CustomChoiceDialogFragment dialog=new CustomChoiceDialogFragment();
        dialog.show(getSupportFragmentManager(),"simple");
    }
}
